<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>充值审核</title>

    <link href="../../resource/css/bootstrap.min.css?v=3.3.5" rel="stylesheet"
          th:href="@{/resource/css/bootstrap.min.css(v=3.3.5)}"/>
    <link href="../../resource/css/font-awesome.min.css?v=4.4.0" rel="stylesheet"
          th:href="@{/resource/css/font-awesome.min.css(v=4.4.0)}"/>
    <!-- Morris -->
    <link href="http://cdn.viptool.cn/lib/morris.js/0.4.3/morris.css" rel="stylesheet">
    <link href="../../resource/css/animate.min.css" rel="stylesheet" th:href="@{/resource/css/animate.min.css}"/>

    <link href="../../resource/css/style.min.css?v=4.0.0" rel="stylesheet"
          th:href="@{/resource/css/style.min.css(v=4.0.0)}"/>
    <link href="../../resource/hotui/css/hotui.style.override.css"
          th:href="@{/resource/hotui/css/hotui.style.override.css}" rel="stylesheet"/>
    <style type="text/css">
        .hr-line-dashed {
            margin: 10px 0;
            height: 1px;
            border-top: 1px dashed #e7eaec;
            background-color: #fff;
            color: #fff;
        }
    </style>
    <script crossorigin="anonymous" integrity="sha256-LJplw+2NCyooGTb3A1rW5PtJunpaFSDnLvKI3vI7/m0="
            src="//cdnjs.cloudflare.com/ajax/libs/viewerjs/1.3.7/viewer.min.js"></script>
    <link crossorigin="anonymous" href="//cdnjs.cloudflare.com/ajax/libs/viewerjs/1.3.7/viewer.min.css"
          integrity="sha256-3DoDl+LLfiTu3XDFHk/sZfM9WKF5H/eVBUsQVOTXUe8=" rel="stylesheet"/>
</head>

<body class="gray-bg">

<div id="receiptHome">

</div>

<div class="wrapper wrapper-content tooltip-demo">
    <!--search-->
    <form role="form" id="searchForm" class="search-panel" method="get" th:object="${condition}">
        <input type="hidden" th:value="${pageIndex}" name="pageIndex"/>
        <div class="row">
            <div class="col-lg-12">
                <div class="ibox">
                    <div class="ibox-content">
                        <div class="form-inline">
                            <div class="form-group m-r-sm">
                                <label class=" control-label" for="userKey">姓名：</label>
                                <input type="text" class="form-control input-sm mb10" id="userKey" th:value="*{userKey}"
                                       name="userKey" placeholder="账户/姓名" style="width: 156px;"/>
                            </div>
                            <div class="form-group m-r-sm">
                                <button type="button" onclick="listHandler.search(1)"
                                        class="btn btn-primary btn-sm m-b-none searchBtn">筛选
                                </button>
                                <button type="button" onclick="listHandler.searchAll()"
                                        class="btn btn-primary btn-sm m-b-none">显示全部
                                </button>
                                <button type="button" onclick="listHandler.simulation()"
                                        class="btn btn-primary btn-sm m-b-none">消息模拟
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>
    <!--search-->
    <!--list-->
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox float-e-margins m-b-none">
                <div class="tabs-container">
                    <ul class="nav nav-tabs">
                        <li class="active">
                            <a th:href="@{/msg/location}" href="#">定位消息</a>
                        </li>
                        <li>
                            <a th:href="@{/msg/alarm}">警报消息</a>
                        </li>
                        <li>
                            <a th:href="@{/msg/node}">节点消息</a>
                        </li>
                    </ul>
                    <div class="tab-content">
                        <div class="tab-pane active">
                            <div class="panel-body">
                                <table class="table table-bordered table-hover table-center">
                                    <thead>
                                    <tr>
                                        <th>基站编号</th>
                                        <th>定位器编号</th>
                                        <th>卡编号</th>
                                        <th>所属用户</th>
                                        <th>用户类型</th>
                                        <th>上一个消息</th>
                                        <th>创建时间</th>
                                    </tr>
                                    </thead>
                                    <tbody>

                                    <tr th:each="item:${list}">
                                        <td th:text="${item.stationId}"></td>
                                        <td th:text="${item.locatorId}"></td>
                                        <td th:text="${item.cardId}"></td>
                                        <td th:text="${item.realName}"></td>
                                        <td th:text="${item.userType.desc}"></td>
                                        <td th:text="${item.lastMsgId}"></td>
                                        <td th:text="${#temporals.format(item.createTime,'yyyy-MM-dd HH:mm:ss')}"></td>
                                    </tr>
                                    </tbody>
                                </table>
                                <p style="float: left; margin: 20px 0;">
                                    共<span th:text="${totalRecords}"></span>条记录，当前第<span
                                        th:text="${pageIndex}"></span>/<span
                                        th:text="${totalPages==0?1:totalPages}"></span>，每页20条记录
                                </p>
                                <ul style="float: right;" class="pagination pagination-split">
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<div id="msg_simulation_modal" style="display: none;">
    <div class="form-horizontal" style="width: 479px;">
        <div class="form-group form-inline">
            <label class="col-sm-3 control-label">*基站编号：</label>
            <div class="col-sm-9">
                <input type="text" id="msg_stationId" class="form-control input-sm input-s"
                       placeholder="基站编号"/>
            </div>
        </div>
        <div class="form-group form-inline">
            <label class="col-sm-3 control-label">*定位器编号：</label>
            <div class="col-sm-9">
                <input type="text" id="msg_locatorId"
                       class="form-control input-sm input-s" placeholder="定位器编号"/>
            </div>
        </div>
        <div class="form-group form-inline">
            <label class="col-sm-3 control-label">*卡编号：</label>
            <div class="col-sm-9">
                <input type="text" id="msg_cardId" class="form-control input-sm input-s"
                       placeholder="卡编号"/>
            </div>
        </div>
        <div class="form-group form-inline">
            <label class="col-sm-3 control-label">*消息类型：</label>
            <div class="col-sm-9">
                <select id="msg_type">
                    <option value="0">定位消息</option>
                    <option value="1">报警消息</option>
                </select>
            </div>
        </div>
    </div>
</div>

<!--基础框架js-->
<script src="../../resource/js/jquery.min.js?v=2.1.4" th:src="@{/resource/js/jquery.min.js(v=2.1.4)}"></script>
<script src="../../resource/js/bootstrap.min.js?v=3.3.5" th:src="@{/resource/js/bootstrap.min.js(v=3.3.5)}"></script>
<script src="../../resource/hotui/js/hot/bootstrap.hot.extra-utils.js"
        th:src="@{/resource/hotui/js/hot/bootstrap.hot.extra-utils.js(123123)}"></script>
<script src="../../resource/hotui/js/hot/bootstrap.hot.extra-init.js"></script>

<script src="../../resource/hotui/js/content.min.js" th:src="@{/resource/hotui/js/content.min.js}"></script>

<script type="text/javascript" th:inline="javascript">
    const pageIndex = /*[[${pageIndex}]]*/  1;
    const totalPages = /*[[${totalPages}]]*/  1;
    const pageUri = /*[[@{/msg/location}]]*/  "";
    const apiUri = /*[[@{/msg}]]*/  "";
</script>
<script>
    var msgSimulationModal = $("#msg_simulation_modal").modal("模拟发送", function () {
        let stationId = $.trim($("#msg_stationId").val());
        let cardId = $.trim($("#msg_cardId").val());
        let locatorId = $.trim($("#msg_locatorId").val());
        let requestData = {
            stationId: stationId,
            cardId: cardId,
            locatorId: locatorId,
            msgType: $("#msg_type").val()
        };

        hot.ajax(apiUri + "/simulation", requestData, function (apiResult) {
            if (apiResult.resultCode === 2000) {
                hot.tip.success("发送成功");
            } else {
                hot.tip.error("发送失败--" + apiResult.resultMsg);
            }
        }, function () {
        }, "post");
    });

    $(function () {
        //初始化分页
        var pageinate = new hot.paging(".pagination", pageIndex, totalPages, 7);

        pageinate.init(function (p) {
            listHandler.search(p);
        });
    });

    var listHandler = {
        search: function (pageIndex) {
            $("input[name=pageIndex]").val(pageIndex);
            $("#searchForm").submit();
        },
        searchAll: function () {
            window.location.href = pageUri + "?userId=" + $("#userId").val();
        },
        simulation: function () {
            msgSimulationModal.show();
        }
    }
</script>
</body>
</html>
